package com.zfj.HashMap;

import java.util.Map;
import java.util.TreeMap;

/**
 * @author zfj
 * @date 2022/3/7 -17:38
 */
public class Demo2 {
	public static void main(String[] args) {
		TreeMap<Student,String> treeMap=new TreeMap<>();
		Student s1=new Student("孙悟空",100);
		Student s2=new Student("猪八戒",101);
		Student s3=new Student("唐三藏",102);
		treeMap.put(s1,"北京");
		treeMap.put(s2,"上海");
		treeMap.put(s3,"杭州");
		System.out.println("元素个数"+treeMap.size());
		System.out.println(treeMap.toString());
		//删除
		treeMap.remove(s1);
		//遍历
		for (Student student : treeMap.keySet()) {
			System.out.println(student+"====="+treeMap.entrySet());
		}
		for (Map.Entry<Student, String> entry : treeMap.entrySet()) {
			System.out.println(entry.getKey()+"=="+entry.getValue());
		}
		//判断
		System.out.println(treeMap.isEmpty());
	}
}
